package org.byqh.dqeai.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.byqh.dqeai.common.Json;
import org.byqh.dqeai.dto.SysSpappDTO;
import org.byqh.dqeai.entity.SysSpapp;
import org.byqh.dqeai.entity.proxy.SysSpappProxy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sysSpapp")
@Tag(name = "系统[SysSpapp] - 应用程序管理")
public class SysSpappController extends BaseController<SysSpapp, SysSpappProxy> {
    /**
     * 分页查询数据
     */
    @PostMapping(value = "/list")
    public Json<List<SysSpapp>> listAll(@RequestBody(required = false) SysSpappDTO dto) {

        return this.listImpl(SysSpapp.class, null);
    }

    /**
     * 删除数据
     */
    @PostMapping(value = "/delete")
    public Json<Boolean> delete(@RequestBody SysSpappDTO dto) {
        try {
            if (dto.getIdList() == null || dto.getIdList().size() == 0) {
                return Json.error();
            }

            this.getEntityDeletable()
                    .where(s -> s.spId().in(dto.getIdList()));
        } catch (Exception ex) {

            return Json.exception(ex);
        }

        return Json.success();
    }
}